package com.soft.javase.ch02.test06;

import java.util.Arrays;

/**
 * @author wangzhisen
 * @Desc TODO
 * @date 2025/4/18
 */
public class User {

    private String name;
    private String address;
    private String phone;

    //一对多关联订单信息   双向关联
    private Order[] orders;

    //下单方法 TODO
    public void xiadan(){
        System.out.println("下单者的姓名："+name);
        System.out.println("下单者的地址："+address);
        System.out.println("下单者的联系方式："+phone);
        for (Order order : orders) {
            if(order != null){
                System.out.println("下单者所属订单的编号："+order.getOid());
            }
        }
    }


    public User() {
    }

    public User(String name, String address, String phone) {
        this.name = name;
        this.address = address;
        this.phone = phone;
    }

    public User(String name, String address, String phone, Order[] orders) {
        this.name = name;
        this.address = address;
        this.phone = phone;
        this.orders = orders;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return address
     */
    public String getAddress() {
        return address;
    }

    /**
     * 设置
     * @param address
     */
    public void setAddress(String address) {
        this.address = address;
    }

    /**
     * 获取
     * @return phone
     */
    public String getPhone() {
        return phone;
    }

    /**
     * 设置
     * @param phone
     */
    public void setPhone(String phone) {
        this.phone = phone;
    }

    /**
     * 获取
     * @return orders
     */
    public Order[] getOrders() {
        return orders;
    }

    /**
     * 设置
     * @param orders
     */
    public void setOrders(Order[] orders) {
        this.orders = orders;
    }

    public String toString() {
        return "User{name = " + name + ", address = " + address + ", phone = " + phone + ", orders = " + Arrays.toString(orders) + "}";
    }
}
